package com.riccardocardin.structured.concurrency.client;

import com.riccardocardin.structured.concurrency.model.Model;
import com.riccardocardin.structured.concurrency.service.RepositoryCache;
import com.riccardocardin.structured.concurrency.service.RepositoryService;
import com.riccardocardin.structured.concurrency.service.RepositoryServiceCacheImpl;
import com.riccardocardin.structured.concurrency.service.RepositoryServiceImpl;
import static com.riccardocardin.structured.concurrency.model.Model.UserId;

import java.util.List;
import java.util.concurrent.ExecutionException;

public class CacheRepositoryDemo {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        RepositoryServiceImpl repositoryServiceImpl = new RepositoryServiceImpl();
        RepositoryCache repositoryCache = new RepositoryCache();
        RepositoryService repositoryService = new RepositoryServiceCacheImpl(
                repositoryServiceImpl, repositoryCache);
        UserId userId = new UserId(1L);
        //UserId userId = new UserId(42L);
        List<Model.Repository> repositories = repositoryService.findRepositories(userId);
        repositories.forEach(System.out::println);
    }
}
